package com.achf.siap.cd.util;

import java.io.File;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 *
 * @author Aureliano
 */
public final class HibernateUtil {

    private static SessionFactory sessionFactory;

    static {
        HibernateUtil.buildSessionFactory();
    }

    public static Session getSession() {
        return sessionFactory.openSession();
    }

    private static void buildSessionFactory() {
        Configuration configuration = new Configuration();
        File hibernateConfig = new File(
            new File("").getAbsolutePath() +
            "/src/main/resources/hibernate.cfg.xml");
        configuration.configure(hibernateConfig);
    }
}